//
//  ShowOrderCell.m
//  YunGou
//
//  Created by macbook on 16/6/3.
//  Copyright © 2016年 macbook. All rights reserved.
//

#import "ShowOrderCell.h"
#import "NSString+DateTransform.h"
#import "NSString+Frame.h"
#import "ShowOrderImageView.h"
#import <UIImageView+WebCache.h>

@interface ShowOrderCell ()
@property (weak, nonatomic) IBOutlet UIImageView *avater;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *winGoodsLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
@property (weak, nonatomic) IBOutlet UILabel *commentLabel;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *commentHeightConstraint;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *winGoodsHeightConstraint;
@property (weak, nonatomic) IBOutlet ShowOrderImageView *imageList;
@end

@implementation ShowOrderCell

- (void)awakeFromNib {
    _avater.layer.cornerRadius = _avater.frame.size.width/2;
    _avater.clipsToBounds = YES;
}

- (void)setShowOrderModel:(ShowOrderModel *)showOrderModel{
    [_avater sd_setImageWithURL:[NSURL URLWithString:[ImageUrl stringByAppendingString:showOrderModel.img]]];
    _nameLabel.text = showOrderModel.username;
    NSString *goodsName =  [NSString stringWithFormat:@"获得奖品：%@", showOrderModel.title];
    _winGoodsLabel.text = goodsName;
    _winGoodsHeightConstraint.constant = [goodsName heightWithFont:[UIFont systemFontOfSize:12] withinWidth:ScreenWidth - 80];
    
    _timeLabel.text = [NSString timeTransformWithString:showOrderModel.q_end_time andFormatter:@"yyyy-MM-dd"];
    _commentLabel.text = showOrderModel.sd_content;
    _commentHeightConstraint.constant = [showOrderModel.sd_content heightWithFont:[UIFont systemFontOfSize:16] withinWidth:ScreenWidth - 80];
    //防止复用问题
    for (UIView *subView in _imageList.subviews) {
        [subView removeFromSuperview];
    }
    [_imageList setImageWithImages:showOrderModel.sd_photolist andWidth:ScreenWidth - 60];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

@end
